def get_kth(mylist, k):
    if not mylist or k < 1:
        raise Exception('非法输入')
    i, j = mylist, mylist
    for _ in range(k - 1):
        j = j.next
        if not j:
            raise Exception('k太大')
    while j.next:
        i = i.next
        j = j.next
    return i


from utils import list12345, print_list, list9, null_list

print_list(list12345)
ans = get_kth(list12345, 4)
print(ans.val)

ans = get_kth(list9, 1)
print(ans.val)

ans = get_kth(null_list, 1)
print(ans.val)
